package service

import (
	"fresh-food/model"
	"fresh-food/response"
	"github.com/gin-gonic/gin"
)

func OrderList(c *gin.Context) {
	var order model.Order
	allOrder, err := order.GetAllOrder()
	if err != nil {
		response.CurrencyErrResponse(c, err.Error(), -1)
		return
	}
	var AllOrderList []*response.OrderList
	for _, v := range allOrder {
		AllOrderList = append(AllOrderList, &response.OrderList{
			Id:         int(v.ID),
			OrderId:    v.OrderId,
			TotalPrice: v.TotalPrice,
			UserId:     v.UserId,
			Status:     v.Status,
		})
	}
	response.CurrencySuccessResponse(c, "所有订单查询成功", map[string]interface{}{"all_order": AllOrderList})
}
